package com.bbt.dormassistant.dao;

import com.bbt.dormassistant.entity.Dormitory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;


@Component
public class DormitoryDao {

    @Autowired
    private MongoTemplate mongoTemplate;

    public Dormitory findByUserId(String userId){
        Query query = Query.query(Criteria.where("userId").is(userId));
        return mongoTemplate.findOne(query,Dormitory.class);
    }

}
